use serde::{Deserialize, Serialize};

/// 线程绑定对象
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ThreadLocalVar {
    /// 线程名称
    thread_name: String,
}

/// 线程绑定变量实现
impl ThreadLocalVar {
    /// 创建新的线程绑定变量
    pub fn new() -> Self {
        ThreadLocalVar {
            thread_name: String::from("")
        }
    }

    /// 获取线程名称
    pub fn get_thread_name(&self) -> &str {
        &self.thread_name
    }

    /// 获取线程名称
    pub fn set_thread_name(&mut self, thread_name: String) {
        self.thread_name = thread_name;
    }
}

/// 实现Default
impl Default for ThreadLocalVar {
    fn default() -> Self {
        ThreadLocalVar::new()
    }
}